<?php
/**
 * SellerService.php
 *
 * @copyright  2023 beikeshop.com - All Rights Reserved
 * @link       https://beikeshop.com
 * @author     Edward Yang <yangjin@guangda.work>
 * @created    2023-04-21 10:12:57
 * @modified   2023-04-21 10:12:57
 */

namespace Beike\Seller\Services;

use Beike\Seller\Repositories\SellerRepo;

class SellerService
{
    /**
     * 注册商户
     *
     * @param array $data // ['email', 'store_name, 'password']
     * @return mixed
     */
    public static function register(array $data)
    {
        $seller['seller_group_id']      = plugin_setting('multi_seller.default_seller_group_id', 0);
        $seller['product_approve']      = plugin_setting('multi_seller.product_approve_default', 0);
        $seller['status']               = ! plugin_setting('multi_seller.approve_seller'); // approve_customer为是否需要审核客户
        $seller['approved']             = ! plugin_setting('multi_seller.approve_seller'); // approve_customer为是否需要审核客户
        $seller['locale']               = locale();
        $seller['email']                = $data['email'];
        $seller['password']             = $data['password'];
        $seller['store_name']           = $data['store_name'];
        $seller['type']                 = $data['type'];
        $seller['id_card']              = $data['id_card'];
        $seller['id_number']            = $data['id_number'];
        $seller['seller_user_group_id'] = 0;
        $seller                         = SellerRepo::create($seller);

        return $seller;
    }
}
